import { apiRequest } from "../request";

/**
 *
 * @param userInfo {userName, passWord}
 * @returns 登陆接口
 */
export function fetchLogin(userInfo: AuthApi.UserInfoRequest){
  return  apiRequest.post<AuthApi.LoginResult, AuthApi.UserInfoRequest>('/login', userInfo);
}

/**
 *
 * @param userInfo {userName, passWord}
 * @returns 获取用户列表
 */
export function fetchUserList(params: AuthApi.UserInfoRequest){
  return  apiRequest.get<Service.ListResult<AuthApi.UserInfoRequest[]>>('/user', { params });
}

/**
 *
 * @param userInfo {userName, passWord，type}
 * @returns 修改用户信息
 */
export function fetchUpdateUser(data: AuthApi.UserInfoRequest){
  return  apiRequest.post<any, AuthApi.UserInfoRequest>('/user/update', data);
}
/**
 *
 * @param userInfo {userName, passWord}
 * @returns 创建用户
 */
export function fetchCreateUser(data: AuthApi.UserInfoRequest){
  return  apiRequest.post<any, AuthApi.UserInfoRequest>('/user/create', data);
}
/**
 *
 * @param userId 用户id
 * @returns 删除用户
 */
export function fetchDeleteUser(userId: AuthApi.UserInfoRequest['userId']){
  return  apiRequest.post<any, { userId: AuthApi.UserInfoRequest['userId'] }>('/user/delete', {userId});
}

/**
 *
 * @param data 更新的页面权限
 * @returns 更新权限
 */
export function fetchUpdateRole(data: any){
  return  apiRequest.post<AuthApi.RoleResult, AuthApi.RoleRequest>('/role/update', data);
}

/**
 *
 * @param data 更新的页面权限
 * @returns 更新权限
 */
export function fetchGetRoleList(params: AuthApi.RoleRequest){
  return  apiRequest.get<AuthApi.RoleResult>('/role', { params });
}
